package com.central.post.controller

import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.central.common.annotation.LoginUser
import com.central.common.entity.Post
import com.central.common.model.CommonResult
import com.central.common.model.PageVo
import com.central.common.model.SysUser
import com.central.post.pojo.newGood.NewGoodDetailVo
import com.central.post.pojo.newGood.NewGoodList
import com.central.post.pojo.newGood.NewGoodSearchDto
import com.central.post.pojo.post.PostDto
import com.central.post.pojo.post.PostSaveOrUpdateDto
import com.central.post.pojo.post.PostVo
import com.central.post.service.NewGoodService
import com.central.post.service.PostService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*
import springfox.documentation.annotations.ApiIgnore

/**
 * @author  fly
 * @date  2021/5/26 14:55
 * @version 1.0
 */
@Api(tags = ["(小程序) 上新模块"])
@RestController
@RequestMapping("post")
open class NewGoodController {

    @Autowired
    private lateinit var newGoodService: NewGoodService


    @ApiOperation("获取上新列表")
    @GetMapping("/getNewGoodListByTime")
    fun getNewGoodListByTime(newGoodSearchDto: NewGoodSearchDto, pageVo: PageVo): CommonResult<Page<NewGoodList>> =
        newGoodService.getNewGoodListByTime(newGoodSearchDto, pageVo)


    @ApiOperation("获取上新详情")
    @GetMapping("/getNewGoodDetail")
    fun getNewGoodDetail(id: Long,  @ApiIgnore @LoginUser sysUser: SysUser, pageVo: PageVo): CommonResult<NewGoodDetailVo> =
        newGoodService.getNewGoodDetail(id, sysUser, pageVo)

    @ApiOperation("订阅上新提醒")
    @PostMapping("/subscribeNewGood")
    fun subscribeNewGood(id: Long, @ApiIgnore @LoginUser sysUser: SysUser): CommonResult<Boolean> =
        newGoodService.subscribeNewGood(id, sysUser)
}
